class Router {
    constructor(data = { describe: '', method: 'get', args: {}, myMiddleware: [], run(req, res, next) { return res.send('') } }) {
        if (Object.prototype.toString.call(data) !== '[object Object]') {
            throw new Error('The parameter of Router must be a Object !')
        }
        if (Object.prototype.toString.call(data.method) !== '[object String]') {
            throw new Error('The Router.method must be a String !')
        }
        if (Object.prototype.toString.call(data.args) !== '[object Object]') {
            throw new Error('The Router.args must be a Object !')
        } else if (Object.keys(data.args).some(arg => Object.prototype.toString.call(data.args[arg]) !== '[object Object]')) {
            throw new Error('The each of Router.args must be a String !')
        } else if (Object.keys(data.args).some(arg => !data.args[arg].type)) {
            throw new Error('The each of Router.args must have a type attribute !')
        }
        if (Object.prototype.toString.call(data.myMiddleware) !== '[object Array]') {
            throw new Error('The Router.myMiddleware must be a Array !')
        } else if (data.myMiddleware.some(_myMiddleware => Object.prototype.toString.call(_myMiddleware) !== '[object String]')) {
            throw new Error('The each of Router.myMiddleware must be a String !')
        }
        if (Object.prototype.toString.call(data.run) !== '[object Function]') {
            throw new Error('The Router.run must be a Function !')
        }
        if (Object.prototype.toString.call(data.describe) !== '[object String]') {
            throw new Error('The Router.describe must be a String !')
        }
        this.describe = data.describe;
        this.method = data.method;
        this.run = data.run;
        this.args = data.args;
        this.myMiddleware = data.myMiddleware;
    }
}

module.exports = Router;